<template>
  <div>
    <!--引用表格-->
   <BasicTable @register="registerTable" :rowSelection="rowSelection">
     <!--插槽:table标题-->
      <template #tableTitle>
          <a-button  type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
      </template>
	  <template #img="{ text }">
		<img :src="baseApiUrl+'/'+VITE_GLOB_BUCKET_NAME+'/'+text" width="50px" height="50px" v-show="text"/>
	  </template>
       <!--操作栏-->
      
      <!--字段回显插槽-->
      <template v-slot:bodyCell="{ column, record, index, text }">
      </template>
    </BasicTable>
    
  </div>
</template>

<script lang="ts" name="dormitory-dormDeviceAccessRecord" setup>
  import {ref, reactive, computed, unref} from 'vue';
  import {BasicTable, useTable, TableAction} from '/@/components/Table';
  import {useModal} from '/@/components/Modal';
  import { useListPage } from '/@/hooks/system/useListPage'
  import {columns, searchFormSchema} from './DormDeviceAccessRecord.data';
  import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './DormDeviceAccessRecord.api';
  import { downloadFile } from '/@/utils/common/renderUtils';
  import { useUserStore } from '/@/store/modules/user';
  import {getAppEnvConfig} from "@/utils/env";
  import {useGlobSetting} from "@/hooks/setting";
  const queryParam = reactive<any>({isVisiter:0});
  const checkedKeys = ref<Array<string | number>>([]);
  const userStore = useUserStore();
  const globSetting = useGlobSetting();
  const {VITE_GLOB_BUCKET_NAME} = getAppEnvConfig();

  const baseApiUrl = globSetting.domainUrl;
  //注册table数据
  const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
      tableProps:{
           title: '宿舍考勤设备刷卡记录',
           api: list,
           columns,
           canResize:false,
           formConfig: {
              //labelWidth: 120,
              schemas: searchFormSchema,
              autoSubmitOnEnter:true,
              showAdvancedButton:true,
              fieldMapToNumber: [
              ],
              fieldMapToTime: [
                 ['accessDate', ['accessDate_begin', 'accessDate_end'], 'YYYY-MM-DD HH:mm:ss'],
              ],
            },
            showActionColumn: false,
           actionColumn: {
               width: 120,
               fixed:'right'
            },
            beforeFetch: (params) => {
              return Object.assign(params, queryParam);
            },
      },
       exportConfig: {
            name:"宿舍考勤设备刷卡记录",
            url: getExportUrl,
            params: queryParam,
          },
          importConfig: {
            url: getImportUrl,
            success: handleSuccess
          },
  })

  const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext

  
   /**
    * 成功回调
    */
  function handleSuccess() {
      (selectedRowKeys.value = []) && reload();
   }
  


</script>

<style scoped>

</style>